package site.jjqzplucky.user.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import site.jjqzplucky.common.annotation.ResponseResult;
import site.jjqzplucky.common.result.Result;
import site.jjqzplucky.user.domain.dto.UserDto;
import site.jjqzplucky.user.domain.form.UserForm;
import site.jjqzplucky.user.domain.po.User;
import site.jjqzplucky.user.service.UserService;


@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
@Slf4j
@ResponseResult
public class userController {

//    final private OrderClient orderClient;
      private final UserService userService;

    @PostMapping("/login")
    public String login(@RequestBody UserForm form) throws Exception {

        return userService.login(form);
    }

    @GetMapping("/cur_user")
    public User curUser(){
        return userService.curUser();
    }

    @PostMapping("/create")
    public Result<?> create(@RequestBody UserDto userDto){
        userService.create(userDto);
        return Result.success();
    }
    @GetMapping("/list")
    public Object list(){
        return "list";
    }
}
